
#ifndef ___HTMLVIEWBASE_H__
#define ___HTMLVIEWBASE_H__

#include <afxhtml.h>
// CNotifyHtmlView html view

#include "html_page_mgr.h"
class CHtmlPage;



class CHtmlViewBase : public CHtmlView
{
	DECLARE_DYNCREATE(CHtmlViewBase)

public:
	CHtmlViewBase();           // protected constructor used by dynamic creation
	virtual ~CHtmlViewBase();
	BOOL Create( CRect const& rc, CWnd* pParent, UINT nID );

	BOOL OpenPage(CHtmlPage* pHtmlPage, BOOL bUseHistory = TRUE);
	CHtmlPage* GetCurrentPage() const;
	void SetResource( CString const& );
	void SetRelative( CString const& );
	void SetViewFocus();

public:
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif
	virtual void OnFinalRelease();

protected:
	virtual void OnCreate() {}
	BOOL OpenPage(CString const& strPath);
	
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support

	DECLARE_MESSAGE_MAP()
	DECLARE_DISPATCH_MAP()
	DECLARE_INTERFACE_MAP()

	virtual void OnDocumentComplete(LPCTSTR lpszURL);
	virtual void OnReady(LPCTSTR lpszURL);

	void CallBackJavaScript(CComPtr<IDispatch> const& pDisp, BOOL bValue);
	void CallBackJavaScript(CComPtr<IDispatch> const& pDisp, LPCWSTR strValue);

private:
	LRESULT WindowProc(UINT msg, WPARAM wParam, LPARAM lParam);
	HRESULT OnShowContextMenu( DWORD dwID, LPPOINT ppt, LPUNKNOWN pcmdtReserved, LPDISPATCH pdispReserved )
	{
		return S_OK;
	}

	HRESULT OnGetHostInfo(DOCHOSTUIINFO *pInfo)
	{
		pInfo->cbSize = sizeof (DOCHOSTUIINFO);

		pInfo->dwFlags = 
			DOCHOSTUIFLAG_DISABLE_SCRIPT_INACTIVE | 
			DOCHOSTUIFLAG_NO3DBORDER | 
			DOCHOSTUIFLAG_NO3DOUTERBORDER |
			DOCHOSTUIFLAG_THEME | 
			DOCHOSTUIFLAG_DISABLE_HELP_MENU ;
		return S_OK;
	}


	void OnDebug( BSTR bstrMsg )
	{
		OutputDebugString( CString(bstrMsg) );
	}

	void OnClose( int flag );


	virtual HRESULT OnGetExternal( LPDISPATCH *lppDispatch )
	{
		*lppDispatch = GetIDispatch(TRUE);
		return S_OK;
	}
	HRESULT CallJavaScript(CString const& strJsCode, BOOL bSafe = TRUE);


	
	BSTR OnLoadString( BSTR bstrPath );
	
private:
	// Resource Path;
	CString					m_strRelative;
	CString					m_strRes;
	CHtmlPageManager		m_history;
	CHtmlPage*				m_pHtmlPage;


	
};





#endif